package org.matrix.basic
{
	public class Matrix2D implements IMatrix2D
	{
		internal var d2:Vector.<Vector.<Number>>;
		
		protected var _numberOfItems:uint;
		public function get numberOfItems():uint						{return _numberOfItems}
		
		protected var _collums:uint;
		public function get collums():uint								{return _collums}
		
		protected var _rows:uint;
		public function get rows():uint									{return _rows}
		
		public function Matrix2D(collums:uint, rows:uint = 0, d2:Vector.<Vector.<Number>> = null)
		{
			super();
			this.d2 = d2;
			_collums = collums;
			_rows = rows == 0 ? collums : rows;
			_numberOfItems =  rows * collums;
			if (d2 == null)
				init();
		}
		
		protected function init():void
		{
			d2 = new Vector.<Vector.<Number>>(collums, true);
			for (var i:uint = collums; i -- >= 1 ;)
				d2[i] = new Vector.<Number>(rows, true);
		}
		
		public function getElement(collums:uint, rows:uint):Number		{return d2[collums][rows]}
		public function setElement(value:Number, collums:uint, rows:uint):void{d2[collums][rows] = value}
	}
}